<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>

<html>
    <head>
     <script>
    	if(document.domain.toString().indexOf("qronet.co.kr") != -1)
			document.domain = 'qronet.co.kr'; 
	</script>
    <%@ include file="/WEB-INF/views/include/common.jsp" %>
	<meta name="AUTHOR" content="QroTech Co., Ltd." />
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="CACHE-CONTROL" content="NO-CACHE">
	<meta http-equiv="PRAGMA" content="NO-CACHE">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link href="/resources/css/Qronet_display.css" rel="stylesheet" media="screen" />
    <title>sub4_1</title>
    </head>
    <body onload="init()">
    	<div class="content" id="menu4-content1">
    			<div class="sub4_header"><img src="/resources/images/QronetHomeImages/sub4-1-header.png"></div>
    			<div class="sub4_1_content">
    				<div class="table_wrapper">
    					<table class="sub4_table" cellpadding="0" cellspacing="0" id="boardList">
    					<thead>
    						<tr>
    							<th width="70px">번호</th>
    							<th width="440px">제목</th>
    							<th width="80px">등록일</th>
    							<th width="70px">조회수</th>
    						</tr>
    					</thead>
    					<tbody>
    						<tr style="cursor:pointer;" onClick="gotoNoticeView(this)">
    							<td id="seq"></td>
    							<td class="left_align" id="title"></td>
    							<td id="regiTime"></td>
    							<td id="viewCnt"></td>
    							<td style="display:none"><input type="hidden" id="textID"></td>
    						</tr>
					<!--	<tr>
    							<td>10</td>
    							<td class="left_align"><a href="Qronet_sub4_1_2.html">언제나 어디서나 당신곁에 큐로넷 웹사이트가 오픈 하였습니다.</a></td>
    							<td>2013.02.07</td>
    							<td>1000</td>
    						</tr> -->
    						
    					</tbody>
    				</table>
    				</div>
    				
    				<div class="pagenation" id="pagenation">
    					<%-- <a><img src="${imgUrl}/QronetHomeImages/page_left_arrow.png"></a>
    					<a>1</a><a>2</a><a>3</a><a>4</a><a>5</a><a>6</a>
    					<a>7</a><a>8</a><a>9</a><a>10</a>
    					<a><img src="${imgUrl}/QronetHomeImages/page_right_arrow.png"></a>  --%>
    				</div>
    			</div>
    			<div class="sub4_footer">COPYRIGHT(C) QROTECH ALL RIGHTS RESERVED.</div>
    		</div><!--sub4-1 end-->
    <form id="theForm" name="theForm" action="" method="post" style="display:none;">
		<input type="hidden" name="textID" id="paramTextID"/>
	</form>
    <script language="javascript">
    var _this = this;
    var markerSetting = {
    		paging:{}
    }
    function init() {
    	markerSetting.paging.page = '<c:out value="${totalPage.page}"/>';
		markerSetting.paging.totalPage ='<c:out value="${totalPage.totalPage}"/>';
		markerSetting.paging.nowSeq = 1;
		
		getBoardList();
    }
    
    function getBoardList() {
    	_this.boardList = tableSync('boardList');
    	var url='noticeList.json';
    	
		var param=markerSetting.paging;
		
		AjaxPost(url, param, function(data){
// 	 		jsonLog(data.boardList);
			$.each(data.boardList,function(index, value){
				value.regiTime = formatter.dateFormatYYYYMMDD(new Date(value.regiTime));
			});
			_this.boardList.tableAutoSync(data.boardList);
			markerSetting.paging.totalPage= data.totalPage.totalPage;
			makePaging();
		});
    }
    
    function makePaging() {
    	$('#pagenation').html("");
		var totalPage = markerSetting.paging.totalPage;
		var nowPage = markerSetting.paging.page;
		var html='';
		var setFunctionName='';
		var index=(nowPage-10);
		var indexCount=0;
		
		var endPage = totalPage / 10;
		if (totalPage % 10 > 0) {
			endPage = endPage + 1;
		}
		if(index>1){
			html+='<a onclick="changePaging('+index+',\'before\''+')"><img src="/resources/images/QronetHomeImages/page_left_arrow.png"/></a>';
		}
// 		//logs('totalPage/20 = '+totalPage/20);
		for(;index<=endPage;index++){
			if((index)==nowPage){
				setFunctionName='';
			}else{
				setFunctionName=' onclick="changePaging('+index+')"';
			}
			
			if(index>0){
					
				html+='<a '+setFunctionName+'>'+index+'</a>';	
				
				indexCount++;
			}
			if(indexCount>9){
				html+='<a onclick="changePaging('+index+',\'after\''+')"><img src="/resources/images/QronetHomeImages/page_right_arrow.png"/></a>';
				break;
			}
			
		}
		$('#pagenation').html(html);
    }
    
    function changePaging(index, option){
		logs('markerSetting.paging.totalPage = '+markerSetting.paging.totalPage);
		if(option==null){
			logs(', index = '+index);
			
			markerSetting.paging.page=index;
			markerSetting.paging.start=0;
			markerSetting.paging.end=0;
			getBoardList();
		}else{
			if(option=='before'){
				var next = index-9;
				while(next<=0){
					next++;
				}
				logs('next = '+next+', index = '+index);
				markerSetting.paging.page=next;
				markerSetting.paging.start=0;
				markerSetting.paging.end=0;
				getBoardList();
			}else if(option=='after'){
				var next = index+9;
				while(next>=(markerSetting.paging.totalPage/10)+1){
					next--;
				}
				logs('next = '+next+', index = '+index);
				markerSetting.paging.page=next;
				markerSetting.paging.start=0;
				markerSetting.paging.end=0;
				getBoardList();
			}
		}
	}
    
    function gotoNoticeView(tr){
    	var textID = $(tr).find("#textID").val();
    	$("#paramTextID").val(textID);
    	
    	$("#theForm").attr("action", "/homepage/noticeView");
    	$("#theForm").submit();
    }
    
    </script>
    </body>
</html>